package com.leef.oauth.data.api.interceptor;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by IWALL on 2017/2/23.
 * Interceptor
 */
public class AuthenticationInterceptor implements Interceptor {

    private String token = "";

    public void setToken(String token) {
        this.token = token;
    }

    public AuthenticationInterceptor() {
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request origin = chain.request();
        Request.Builder builder = origin.newBuilder();
        builder.header("Authorization", "Bearer " + token);
        return chain.proceed(builder.build());
    }
}
